import AdAgent from "./AdAgent";
import PlatUtils from "./PlatUtils";
import AdAgentNative from "./AdAgentNative";
import AdAgentWechat from "./AdAgentWechat";
import AdAgentOPPO from "./AdAgentOPPO";

const { ccclass, property } = cc._decorator;

/**
 * banner 的位置
 */
export enum BannerLocation {
    Home = "Home",
    Level = "Level",
    Game = "Game"
};

@ccclass
export default class AdManager {

    private _curAdAgent: AdAgent = null;

    public Init() {

        if (PlatUtils.IsNativeAndroid) {
            this._curAdAgent = new AdAgentNative();
            this._curAdAgent.Init();
        }else if(PlatUtils.IsWechat){
            this._curAdAgent = new AdAgentWechat();
            this._curAdAgent.Init();
        }else if(PlatUtils.IsOPPO){
            this._curAdAgent = new AdAgentOPPO();
            this._curAdAgent.Init();
        }
    }

    public ShowBanner(location: BannerLocation) {
        if (this._curAdAgent) {
            this._curAdAgent.ShowBanner(location);
        }
    }

    public HideBanner(location: BannerLocation) {
        if (this._curAdAgent) {
            this._curAdAgent.HideBanner(location);
        }
    }

    public  ShowInterstitial() {
        if (this._curAdAgent) {
            this._curAdAgent.ShowInterstitial();
        }
    }

    public ShowVideo(callback: Function){
        if (this._curAdAgent) {
            this._curAdAgent.ShowVideo(callback);
        }
    }

    public GameExit() {
        if (this._curAdAgent) {
            this._curAdAgent.GameExit();
        }
    }

    public Share(){
        if (this._curAdAgent) {
            this._curAdAgent.Share();
        }
    }
}
